package main

import (
	"encoding/json"
	"io/fs"
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"strings"

	"gitee.com/xuender/findzip"
)

var title = []string{"receiver_address", "receiver_name", "receiver_mobile"}

func main() {
	all := []map[string]interface{}{}
	filepath.Walk("/home/ender/文档/312037", func(path string, info fs.FileInfo, err error) error {
		if info.IsDir() || !strings.HasSuffix(path, ".json") {
			return nil
		}
		log.Println(path)
		bs, err := ioutil.ReadFile(path)
		if err != nil {
			return err
		}
		os := []map[string]interface{}{}
		json.Unmarshal(bs, &os)
		for _, o := range os {
			for _, key := range title {
				o[key] = findzip.DecryptAes(o[key].(string))
			}
			all = append(all, o)
		}
		return nil
	})

	j, _ := json.Marshal(all)
	f, _ := os.Create("2021-2.json")
	defer f.Close()
	f.Write(j)
	log.Println("完毕")
}
